package com.guigu.controller.stock;


import com.guigu.pojo.design.DFile;
import com.guigu.pojo.design.DModule;
import com.guigu.pojo.stock.SPay;
import com.guigu.pojo.stock.SPayDetails;
import com.guigu.service.design.DModuleService;
import com.guigu.service.stock.SPayDetailsService;
import com.guigu.service.stock.SPayService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Mr.Zhang
 * @since 2024-12-06
 */
@Controller
@RequestMapping("/s-pay-details")
public class SPayDetailsController {

    @Autowired
    private SPayService spayService;

    @Autowired
    private SPayDetailsService sPayDetailsService;

    @PostMapping("/Audit")
    @ResponseBody
    public Boolean Audit(@RequestBody HashMap<String,Object> map){
        Integer id = Integer.parseInt(map.get("id").toString());
        String checkTag = map.get("checkTag").toString();
        String checker = map.get("checker").toString();
        SPay sPay = new SPay();
        sPay.setId(id);
        sPay.setCheckTag(checkTag);
        sPay.setChecker(checker);
        sPay.setCheckTime(new Date());
        sPay.setCheckTime(new Date());
        boolean b = spayService.updateById(sPay);
        return b;
    }

    @GetMapping("/initialSpayDetails")
    @ResponseBody
    public SPayDetails initialSpayDetails(HttpServletRequest req){
        Integer id = StringUtils.isNotBlank(req.getParameter("id")) ? Integer.parseInt(req.getParameter("id")) : null;
        SPayDetails sPayDetails = sPayDetailsService.selectById(id);

        return sPayDetails;
    }
}

